import QtQuick 2.0
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import "qrc:/qmlComponents/CustomizedUIElement"
import "qrc:/qmlComponents/ConfigManager"
import ConfigElementType 1.0
import "qrc:/qmlComponents/CustomizedUIElement"
import QtQuick.Dialogs 1.2
import FileContentItem 1.0

Item {
    property var maxListHeight: 700
    width:  600
    height: 700
    Component{
        id: aaAnalysisConfigger
        ColumnLayout {
            GroupBox {
                title: qsTr("AA Analysis")
                RowLayout {
                    ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaAnalysisStartPos"
                        Component.onCompleted: {
                            init(ConfigElementType.Double)
                        }
                    }
                    ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaAnalysisStepSize"
                        Component.onCompleted: {
                            init(ConfigElementType.Int)
                        }
                    }
                    ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaAnalysisDelayInMs"
                        Component.onCompleted: {
                            init(ConfigElementType.Int)
                        }
                    }
                    ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaAnalysisCount"
                        Component.onCompleted: {
                            init(ConfigElementType.Int)
                        }
                    }
                }
            }
            GroupBox {
                title: qsTr("FOV Analysis")
                RowLayout{
                    ConfigRow{
                         configModel: aaCoreConfig
                         configName: "EFL"
                         Component.onCompleted: {
                             init(ConfigElementType.Double)
                         }
                    }
                    ConfigRow{
                         configModel: aaCoreConfig
                         configName: "FOVSlope"
                         Component.onCompleted: {
                             init(ConfigElementType.Double)
                         }
                    }
                    ConfigRow{
                         configModel: aaCoreConfig
                         configName: "EstimatedAAFOV"
                         Component.onCompleted: {
                             init(ConfigElementType.Double)
                         }
                    }
                    Button {
                        text: qsTr("FOV Calibration")
                        onClicked: {
                            tem.runSingleCmd(aaCore, "performFOVCalibration")
                        }
                    }
                }
            }

            GroupBox {
                title: qsTr("Tilt Analysis")
                RowLayout {
                   ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaCalibrationTiltNeedReverse"
                        Component.onCompleted: {
                            init(ConfigElementType.Bool)
                        }
                   }
                   ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaCalibrationXTilt"
                        Component.onCompleted: {
                            init(ConfigElementType.Double)
                        }
                   }
                   ConfigRow{
                        configModel: aaCoreConfig
                        configName: "aaCalibrationYTilt"
                        Component.onCompleted: {
                            init(ConfigElementType.Double)
                        }
                   }
                }
            }
            GroupBox {
                title: qsTr("AA Tilt Test")
                RowLayout {
                    Button {
                        text: qsTr("AA Test")
                        onClicked: {
                            tem.runSingleCmd(aaCore, "performAATest")
                        }
                    }

                    Button {
                        text: qsTr("AA Tilt Calibration")
                        onClicked: {
                            tem.runSingleCmd(aaCore, "performAATiltCalibration")
                        }
                    }
                }
            }
        }

    }

    MyTabView{
        id: viewer
        anchors.fill: parent
    }

    Component.onCompleted: {
        viewer.addTab("AA Core", aaAnalysisConfigger)
    }
}
